/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-06-19
 * Time: 20:14
 */

/**
 * 消失的数字，第二次复习
 *
 */
class Solution {
    public int missingNumber(int[] nums) {
        int data = 0;
        for (int i = 0; i < nums.length; i++) {
            //数组里所有元素，异或包括下标
            data ^= nums[i];
            //下标
            data ^= i;

        }
        return  data ^= nums.length; //最后要与，数组元素个数异或

    }
}
public class Test {
    public static void main(String[] args) {
        Solution solution = new Solution();

        int[] array = new int[]{9,6,4,2,3,5,7,0,1};
        System.out.println(solution.missingNumber(array));
    }
}
